package API.Stream.Practise;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class FilterAndToMap {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("zhangsan,23");
        list.add("lisi,24");
        list.add("wangwu,25");
        Map<String, Integer> map = list.stream().filter(s -> Integer.parseInt(s.split(",")[1]) >= 24).
                collect(Collectors.toMap(
                        s ->  s.split(",")[0],
                        s ->  Integer.parseInt(s.split(",")[1])
                ));
        map.forEach((k, y) -> System.out.println(k + " : " + y));
    }
}
